#@adminLayout()


#define adminMain()
<section class="content-header">
      <h1>
        友情链接管理
      </h1>
      <ol class="breadcrumb">
        <li><a href="/admin"><i class="fa fa-dashboard"></i> 主页</a></li>
        <li class="active"><a href="/admin/friendlink">友情链接管理</a></li>
      </ol>
</section>

<section class="content">
	<div class="row">
		<div class="box">
            <div class="box-header with-border">
              <h3 class="box-title">友情链接列表</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table class="table table-bordered">
                <tbody><tr>
                  <th style="width: 20px">id</th>
                  <th style="width: 150px">网站名</th>
                  <th>网站logo</th>
                  <th>网站url</th>
                  <th>操作</th>
                </tr>
                #for(link : friendLinks)
                <tr>
                  <td>#(link.id).</td>
                  <td>#(link.site_name)</td>
                  <td><img src="#(link.logo)" alt="" style="width: 80px;height: auto;"></td>
                  <td>#(link.url)</td>
                  <td>
	                  <button class="btn btn-danger btn-xs" type="button" onclick="delLink(#(link.id))">
	                  	<i class="ion ion-close"></i>&nbsp;删除
	                  </button>
              	  </td>
                </tr>
                #end
              </tbody></table>
            </div>

          </div>
	</div>
</section>
#end

#define js()
<script type="text/javascript">
  function delLink(_id){
    //询问框
    layer.confirm('您确定要删除该日志吗？', {
      btn: ['确定','取消'] //按钮
    }, function(){
      $.ajax("/admin/friendlink/delete", {
        type: "POST"
        , cache: false
        , dataType: "json"
        , data: {
          linkId: _id,
        }
        , beforeSend: function() {
      
        }
        , success: function(ret) {
          if (ret.isOk) {
            layer.msg(ret.msg, {
              shift: 6
              , shade: 0.3
              , time: 3000
              , offset: "165px"
              , closeBtn: 1
              , shadeClose: true
            });
            //刷新页面
             window.location.reload();
            return ;

          } else {
            layer.msg(ret.msg, {
              shift: 6
              , shade: 0.3
              , time: 3000
              , offset: "165px"
              , closeBtn: 1
              , shadeClose: true
            });
            return ;
          }
        }
        , complete: function() {
          //do nothing
        }
      }); 
    }, function(){
      
    });
  }

  function delAllLog(_id){
    //询问框
    layer.confirm('您确定要删除所有日志吗？', {
      btn: ['确定','取消'] //按钮
    }, function(){
      $.ajax("/admin/log/deleteAll", {
        type: "POST"
        , cache: false
        , dataType: "json"
        , data: {
          logId: _id,
        }
        , beforeSend: function() {
      
        }
        , success: function(ret) {
          if (ret.isOk) {
            layer.msg(ret.msg, {
              shift: 6
              , shade: 0.3
              , time: 3000
              , offset: "165px"
              , closeBtn: 1
              , shadeClose: true
            });
            //刷新页面
             window.location.reload();
            return ;

          } else {
            layer.msg(ret.msg, {
              shift: 6
              , shade: 0.3
              , time: 3000
              , offset: "165px"
              , closeBtn: 1
              , shadeClose: true
            });
            return ;
          }
        }
        , complete: function() {
          //do nothing
        }
      }); 
    }, function(){
      
    });
  }

</script>
#end